|
|
|
| Table 6.6 Constants for Each Variant Data Type. | | Data Type | VB Constant | VarType() Return Value | | Empty | vbEmpty | 0 | | Null | vbNull | 1 | | Integer | vbInteger | 2 | | Long | vbLong | 3 | | Single | vbSingle | 4 | | Double | vbDouble | 5 | | Currency | vbCurrency | 6 | | Date/Time | vbDate | 7 | | String | vbString | 8 | | Object | vbObject | 9 | | Error | vbError | 10 | | Boolean | vbBoolean | 11 | | Variant | vbVariant | 12 (only used for arrays of variants) | | DataObject | vbDataObject | 13 | | Byte | vbByte | 17 | | Array | vbArray | 8192 |
|
|
|
|
|
|
If you have a Variant variable, you can perform the following testing to determine its type: |
|
|
|
 |
|
|
|
|
If VarType(mvntVar) = vbBoolean Then
...
End If |
|
|
|
|
|
|
|
|
In the example, you can see two different command buttons at the bottom of the Variants.frm form. Under each of these buttons is code that sets the value of a module-level variable named mvntVar to a specific data type. The code then uses the VarType() function to return the numeric return value. |
|
|
|
|
|